"""
    Diagnostics

Main module for GSI diagnostic file I/O.

This module provides complete functionality for reading and writing
GSI-compatible diagnostic files.
"""
module Diagnostics

# Load submodules in correct order
include("FortranBinaryIO.jl")
include("DiagnosticFileFormat.jl")

# Now we can use the types from these modules
using .FortranBinaryIO: FortranFile, open_fortran_file, close_fortran_file,
    write_fortran_record, read_fortran_record, write_fortran_header, read_fortran_header,
    write_fortran_string, read_fortran_string,
    set_byte_order!, get_byte_order
using .DiagnosticFileFormat: DiagnosticHeader, ObservationRecord, GridMetadata,
    create_diagnostic_header, pack_observation_record, unpack_observation_record,
    OBSERVATION_TYPES, OBSERVATION_SUBTYPES, get_obs_type_code, get_obs_subtype_code,
    compute_innovation_statistics

# Export everything from submodules
export FortranFile, open_fortran_file, close_fortran_file
export write_fortran_record, read_fortran_record, write_fortran_header, read_fortran_header
export write_fortran_string, read_fortran_string
export set_byte_order!, get_byte_order

export DiagnosticHeader, ObservationRecord, GridMetadata
export create_diagnostic_header, pack_observation_record, unpack_observation_record
export OBSERVATION_TYPES, OBSERVATION_SUBTYPES
export get_obs_type_code, get_obs_subtype_code
export compute_innovation_statistics

# Include writers and readers after base modules are loaded
include("DiagnosticWriters_Standalone.jl")
include("DiagnosticReaders_Standalone.jl")

# Export writer and reader functions
export write_diag_obs_anl, write_diag_obs_ges
export write_innovation_diagnostics_binary
export write_fit_statistics_binary
export write_qc_diagnostics_binary
export write_all_diagnostics
export DiagnosticOutput

export read_diag_obs_file, read_fit_statistics, validate_diagnostic_file
export compare_diagnostic_files, DiagnosticFileInfo

end # module Diagnostics
